'''
Created on 2010-10-18

@author: DouglasWin7
'''
from google.appengine.ext import db

class distinction(db.Model):
    name = db.StringProperty()
    point = db.IntegerProperty()
    
    @staticmethod
    def get_point(name):
        query = db.GqlQuery("SELECT * FROM distinction WHERE name=:1",name)
        return query.get()
    
    @staticmethod
    def add_point(name, point):
        result = distinction.get_point(name)
        if result!= None :
            result.point += result.point
            result.put()
        else:
            dist = distinction(name=name,point=point)
            dist.put()
            
    @staticmethod
    def get_all_distinctions():
        query = db.GqlQuery("SELECT * FROM distinction")
        return query.fetch(100)    
